package com.zjzywl.smoke.repository;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.zjzywl.smoke.entity.AlarmType;


@Repository
public interface AlarmTypeRepository extends JpaRepository<AlarmType,Integer> {

	//根据警报编码查询信息
    @Query("select u from AlarmType u where u.alarmCode=:code")
    AlarmType findByAlarmCode(@Param("code") String code);
    
    //根据警报编码查询信息
    @Query("select u from AlarmType u where u.alarmTypeId=:id")
    AlarmType findByAlarmId(@Param("id") Integer id);
    
    //修改操作
    @Modifying
	@Transactional
    @Query("update AlarmType u set u.alarmName=:name,u.alarmLevel=:level where u.alarmCode=:code")
    void updateAlarmType(@Param("name") String name,@Param("level") Integer level,@Param("code") String code);
    
}
